#[allow(dead_code)]
pub struct StatusCode(u16);

#[allow(dead_code)]
impl StatusCode {
    pub const HTTP_STATUS_START: u16 = 100;
    pub const HTTP_CONTINUE: u16 = 100;
    pub const HTTP_SWITCHING_PROTOCOLS: u16 = 101;
    pub const HTTP_PROCESSING: u16 = 102;
    pub const HTTP_OK: u16 = 200;
    pub const HTTP_CREATED: u16 = 201;
    pub const HTTP_ACCEPTED: u16 = 202;
    pub const HTTP_NON_AUTHORITATIVE_INFORMATION: u16 = 203;
    pub const HTTP_NO_CONTENT: u16 = 204;
    pub const HTTP_RESET_CONTENT: u16 = 205;
    pub const HTTP_PARTIAL_CONTENT: u16 = 206;
    pub const HTTP_MULTI_STATUS: u16 = 207;
    pub const HTTP_ALREADY_REPORTED: u16 = 208;
    pub const HTTP_IM_USED: u16 = 226;
    pub const HTTP_MULTIPLE_CHOICES: u16 = 300;
    pub const HTTP_MOVED_PERMANENTLY: u16 = 301;
    pub const HTTP_FOUND: u16 = 302;
    pub const HTTP_SEE_OTHER: u16 = 303;
    pub const HTTP_NOT_MODIFIED: u16 = 304;
    pub const HTTP_USE_PROXY: u16 = 305;
    pub const HTTP_TEMPORARY_REDIRECT: u16 = 307;
    pub const HTTP_PERMANENT_REDIRECT: u16 = 308;
    pub const HTTP_BAD_REQUEST: u16 = 400;
    pub const HTTP_UNAUTHORIZED: u16 = 401;
    pub const HTTP_PAYMENT_REQUIRED: u16 = 402;
    pub const HTTP_FORBIDDEN: u16 = 403;
    pub const HTTP_NOT_FOUND: u16 = 404;
    pub const HTTP_METHOD_NOT_ALLOWED: u16 = 405;
    pub const HTTP_NOT_ACCEPTABLE: u16 = 406;
    pub const HTTP_PROXY_AUTHENTICATION_REQUIRED: u16 = 407;
    pub const HTTP_REQUEST_TIMEOUT: u16 = 408;
    pub const HTTP_CONFLICT: u16 = 409;
    pub const HTTP_GONE: u16 = 410;
    pub const HTTP_LENGTH_REQUIRED: u16 = 411;
    pub const HTTP_PRECONDITION_FAILED: u16 = 412;
    pub const HTTP_PAYLOAD_TOO_LARGE: u16 = 413;
    pub const HTTP_URI_TOO_LONG: u16 = 414;
    pub const HTTP_UNSUPPORTED_MEDIA_TYPE: u16 = 415;
    pub const HTTP_RANGE_NOT_SATISFIABLE: u16 = 416;
    pub const HTTP_EXPECTATION_FAILED: u16 = 417;
    pub const HTTP_IM_A_TEAPOT: u16 = 418;
    pub const HTTP_MISDIRECTED_REQUEST: u16 = 421;
    pub const HTTP_UNPROCESSABLE_ENTITY: u16 = 422;
    pub const HTTP_LOCKED: u16 = 423;
    pub const HTTP_FAILED_DEPENDENCY: u16 = 424;
    pub const HTTP_TOO_EARLY: u16 = 425;
    pub const HTTP_UPGRADE_REQUIRED: u16 = 426;
    pub const HTTP_PRECONDITION_REQUIRED: u16 = 428;
    pub const HTTP_TOO_MANY_REQUESTS: u16 = 429;
    pub const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE: u16 = 431;
    pub const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: u16 = 451;
    pub const HTTP_INTERNAL_SERVER_ERROR: u16 = 500;
    pub const HTTP_NOT_IMPLEMENTED: u16 = 501;
    pub const HTTP_BAD_GATEWAY: u16 = 502;
    pub const HTTP_SERVICE_UNAVAILABLE: u16 = 503;
    pub const HTTP_GATEWAY_TIMEOUT: u16 = 504;
    pub const HTTP_HTTP_VERSION_NOT_SUPPORTED: u16 = 505;
    pub const HTTP_VARIANT_ALSO_NEGOTIATES: u16 = 506;
    pub const HTTP_INSUFFICIENT_STORAGE: u16 = 507;
    pub const HTTP_LOOP_DETECTED: u16 = 508;
    pub const HTTP_NOT_EXTENDED: u16 = 510;
    pub const HTTP_NETWORK_AUTHENTICATION_REQUIRED: u16 = 511;
    pub const HTTP_STATUS_END: u16 = 999;
}

#[allow(dead_code)]
pub fn get_status_reason(status_code: u16) -> &'static str {
    match status_code {
        100 => "Continue",
        101 => "Switching Protocols",
        102 => "Processing",
        200 => "OK",
        201 => "Created",
        202 => "Accepted",
        203 => "Non Authoritative Information",
        204 => "No Content",
        205 => "Reset Content",
        206 => "Partial Content",
        207 => "Multi-Status",
        208 => "Already Reported",
        226 => "IM Used",
        300 => "Multiple Choices",
        301 => "Moved Permanently",
        302 => "Found",
        303 => "See Other",
        304 => "Not Modified",
        305 => "Use Proxy",
        307 => "Temporary Redirect",
        308 => "Permanent Redirect",
        400 => "Bad Request",
        401 => "Unauthorized",
        402 => "Payment Required",
        403 => "Forbidden",
        404 => "Not Found",
        405 => "Method Not Allowed",
        406 => "Not Acceptable",
        407 => "Proxy Authentication Required",
        408 => "Request Timeout",
        409 => "Conflict",
        410 => "Gone",
        411 => "Length Required",
        412 => "Precondition Failed",
        413 => "Payload Too Large",
        414 => "URI Too Long",
        415 => "Unsupported Media Type",
        416 => "Range Not Satisfiable",
        417 => "Expectation Failed",
        418 => "I'm a teapot",
        421 => "Misdirected Request",
        422 => "Unprocessable Entity",
        423 => "Locked",
        424 => "Failed Dependency",
        425 => "Too Early",
        426 => "Upgrade Required",
        428 => "Precondition Required",
        429 => "Too Many Requests",
        431 => "Request Header Fields Too Large",
        451 => "Unavailable For Legal Reasons",
        500 => "Internal Server Error",
        501 => "Not Implemented",
        502 => "Bad Gateway",
        503 => "Service Unavailable",
        504 => "Gateway Timeout",
        505 => "HTTP Version Not Supported",
        506 => "Variant Also Negotiates",
        507 => "Insufficient Storage",
        508 => "Loop Detected",
        510 => "Not Extended",
        511 => "Network Authentication Required",

        _ => "Unknow",
    }
}

#[allow(dead_code)]
pub fn http_body_allow_status(status_code: u16) -> bool {
    if (100..=199).contains(&status_code) {
        return false;
    }

    if status_code == 204 {
        return false;
    }

    if status_code == 304 {
        return false;
    }

    true
}
